﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPageAdmin.master" AutoEventWireup="true" CodeFile="Add_Ebook.aspx.cs" Inherits="Admin_Add_Ebook" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        .style15
        {
            width: 280px;
            text-align: right;
        }
        .style16
        {
            font-weight: bold;
            color: #66CCFF;
        }
        .style14
        {
            width: 7px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table class="style7">
        <tr>
            <td colspan="3" style="text-align: center">
                <asp:Label ID="Label2" runat="server" 
                    style="color: #CC9900; font-size: xx-large; font-weight: 700" Text="Add Ebook"></asp:Label>
            </td>
        </tr>
        <tr>
            <td colspan="3" style="text-align: center">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style15">
                <asp:Label ID="Label5" runat="server" CssClass="style16" Text="Title"></asp:Label>
            </td>
            <td class="style14">
                &nbsp;</td>
            <td>
                <asp:TextBox ID="txtTitle" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style15">
                <asp:Label ID="Label4" runat="server" CssClass="style16" Text="ISBN"></asp:Label>
            </td>
            <td class="style14">
                &nbsp;</td>
            <td>
                <asp:TextBox ID="txtIsbn" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style15">
                <asp:Label ID="Label6" runat="server" CssClass="style16" Text="File path"></asp:Label>
            </td>
            <td class="style14">
                &nbsp;</td>
            <td>
                <asp:FileUpload ID="FileUpload" runat="server" />
            </td>
        </tr>
        <tr>
            <td class="style15">
                <asp:Label ID="Label7" runat="server" CssClass="style16" Text="Category ID"></asp:Label>
            </td>
            <td class="style14">
                &nbsp;</td>
            <td>
                <asp:DropDownList ID="ddlCategory" runat="server" DataSourceID="SqlDataSource2" 
                    DataTextField="categoryId" DataValueField="categoryId">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                    SelectCommand="SELECT [categoryId] FROM [tblEbookCategory]">
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="style15" valign="top">
                <asp:Label ID="Label8" runat="server" CssClass="style16" Text="Upload date"></asp:Label>
            </td>
            <td class="style14">
                &nbsp;</td>
            <td>
                <asp:Calendar ID="Calendar" runat="server"></asp:Calendar>
            </td>
        </tr>
        <tr>
            <td class="style15">
                <asp:Label ID="Label9" runat="server" CssClass="style16" Text="Upload ID"></asp:Label>
            </td>
            <td class="style14">
                &nbsp;</td>
            <td>
                <asp:DropDownList ID="ddlUploadid" runat="server">
                    <asp:ListItem></asp:ListItem>
                    <asp:ListItem Value="1">Administartor</asp:ListItem>
                    <asp:ListItem Value="2">Staff</asp:ListItem>
                    <asp:ListItem Value="3">Lecturer</asp:ListItem>
                    <asp:ListItem Value="4">Uploader</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="style15">
                &nbsp;</td>
            <td class="style14">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style15">
                <asp:Label ID="lbMsg" runat="server" style="font-size: medium; color: #FF0000"></asp:Label>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                    DeleteCommand="DELETE FROM [tblEbook] WHERE [ebookId] = @ebookId" 
                    InsertCommand="INSERT INTO [tblEbook] ([ISBN], [ebookTitle], [filePath], [categoryId], [uploadedDate], [uploadedUserId]) VALUES (@ISBN, @ebookTitle, @filePath, @categoryId, @uploadedDate, @uploadedUserId)" 
                    SelectCommand="SELECT * FROM [tblEbook]" 
                    UpdateCommand="UPDATE [tblEbook] SET [ISBN] = @ISBN, [ebookTitle] = @ebookTitle, [filePath] = @filePath, [categoryId] = @categoryId, [uploadedDate] = @uploadedDate, [uploadedUserId] = @uploadedUserId WHERE [ebookId] = @ebookId">
                    <DeleteParameters>
                        <asp:Parameter Name="ebookId" Type="Int32" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="ISBN" Type="String" />
                        <asp:Parameter Name="ebookTitle" Type="String" />
                        <asp:Parameter Name="filePath" Type="String" />
                        <asp:Parameter Name="categoryId" Type="Int32" />
                        <asp:Parameter Name="uploadedDate" Type="DateTime" />
                        <asp:Parameter Name="uploadedUserId" Type="Int32" />
                        <asp:Parameter Name="ebookId" Type="Int32" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:ControlParameter ControlID="txtIsbn" Name="ISBN" PropertyName="Text" 
                            Type="String" />
                        <asp:ControlParameter ControlID="txtTitle" Name="ebookTitle" 
                            PropertyName="Text" Type="String" />
                        <asp:ControlParameter ControlID="FileUpload" Name="filePath" 
                            PropertyName="FileName" Type="String" />
                        <asp:ControlParameter ControlID="ddlCategory" Name="categoryId" 
                            PropertyName="SelectedValue" Type="Int32" />
                        <asp:ControlParameter ControlID="Calendar" Name="uploadedDate" 
                            PropertyName="SelectedDate" Type="DateTime" />
                        <asp:ControlParameter ControlID="ddlUploadid" Name="uploadedUserId" 
                            PropertyName="SelectedValue" Type="Int32" />
                    </InsertParameters>
                </asp:SqlDataSource>
            </td>
            <td class="style14">
                &nbsp;</td>
            <td>
                <asp:Button ID="btnAdd" runat="server" Text="Add" onclick="btnAdd_Click" />
            </td>
        </tr>
    </table>
</asp:Content>

